home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / files.swg / 0097_HEX File reader.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-11-29  |  8.9 KB  |  338 lines

  1.  
  2. (*This is a short and rather unoptomized and well to be honest SLOPPY     *)
  3. (*representation of hex viewing (not editing) what this program WILL      *)
  4. (*do however is go in and suck out the readable text in an exe dat com    *)
  5. (*or other hex file so you can take a look see at whats in em :)          *)
  6. (* This is VERY basic and is just to show the basic concept..             *)
  7.  
  8. (*This code was written by George Slaterpryce A.K.A. Illogical Error      *)
  9. (*you can use it freely i dont really care what you do with it            *)
  10. (*but if you use the concept behind it or the code itself just drop me a  *)
  11. (*line or two at rapter@aug.com i would appreciate it....    also         *)
  12. (**)
  13. (*The author of this code (George Slaterpryce) is not responsible for what*)
  14. (*it does to software/hardware on your computer you use it at your own risk*)
  15. (**)
  16. (*p.s. but it works fine on my 386, 486, and p133 *)
  17.  
  18.  
  19. program ReadFile;
  20. uses crt;
  21. var
  22.   F: file of string;
  23.   f2 : file of char;
  24.   f3 : file of integer;
  25.   f4 : text;
  26.   strng: string;
  27.   ch   : char;
  28.   num, count  : integer;
  29.   didit : boolean;
  30.  
  31. (*Do all my error notices*)
  32. (****************************************************************************)
  33. procedure notice (var didit : boolean);
  34.    begin
  35.    clrscr;
  36.    writeln;
  37.    writeln;
  38.    writeln('P.G.T.F.R.U. ReadFile.exe');
  39.    Writeln('Pascal Genorated Typed File Reader Utility by George Slaterpryce');
  40.    writeln('(C) 1996 George Slaterpryce A.K.A. Illogical Error');
  41.    Writeln('This utility is Freeware.');
  42.    Writeln;
  43.    writeln('Usage ReadFile /[S,C,#,T,?] <filename.dat>');
  44.    textcolor(blue);write('               option');textcolor(green);write('      file name');
  45.    writeln('');
  46.    textcolor(7);
  47.    writeln;
  48.    writeln('Command line Parameters');
  49.    writeln('/S   Reads file of strings');
  50.    writeln('/C   Reads file of chars');
  51.    writeln('/#   Reads file of Integers');
  52.    writeln('/T   Reads Text Files');
  53.    writeln('/?   This Help Screen');
  54.    didit := true;
  55.    end;
  56.  
  57.  
  58. procedure notice1(var didit : boolean);
  59.    begin
  60.    clrscr;
  61.    writeln;
  62.    writeln;
  63.    writeln('P.G.T.F.R.U. ReadFile.exe');
  64.    Writeln('Pascal Genorated Typed File Reader Utility by George Slaterpryce');
  65.    writeln('(C) 1996 George Slaterpryce A.K.A. Illogical Error');
  66.    Writeln('This utility is Freeware.');
  67.    Writeln;
  68.    writeln('Usage ReadFile /[S,C,#,T,?] <filename.dat>');
  69.    textcolor(17);write('               option');textcolor(green);write('      file name');
  70.    writeln('');
  71.    textcolor(7);
  72.    writeln;
  73.    writeln('Command line Parameters');
  74.    writeln('/S   Reads file of strings');
  75.    writeln('/C   Reads file of chars');
  76.    writeln('/#   Reads file of Integers');
  77.    writeln('/T   Reads Text Files');
  78.    writeln('/?   This help screen');
  79.    didit := true;
  80.    end;
  81.  
  82. procedure notice2(var didit : boolean);
  83.    begin
  84.    clrscr;
  85.    writeln;
  86.    writeln;
  87.    writeln('P.G.T.F.R.U. ReadFile.exe');
  88.    Writeln('Pascal Genorated Typed File Reader Utility by George Slaterpryce');
  89.    writeln('(C) 1996 George Slaterpryce A.K.A. Illogical Error');
  90.    Writeln('This utility is Freeware.');
  91.    Writeln;
  92.    writeln('Usage ReadFile /[S,C,#,T,?] <filename.dat>');
  93.    textcolor(blue);write('               option');textcolor(18);write('      file name');
  94.    writeln('');
  95.    textcolor(7);
  96.    writeln;
  97.    writeln('Command line Parameters');
  98.    writeln('/S   Reads file of strings');
  99.    writeln('/C   Reads file of chars');
  100.    writeln('/#   Reads file of Integers');
  101.    writeln('/T   Reads Text Files');
  102.    writeln('/?   This Help Screen');
  103.    didit := (true);
  104.    end;
  105.  
  106. procedure notice3;
  107.    begin
  108.    clrscr;
  109.    writeln;
  110.    writeln;
  111.    writeln('P.G.T.F.R.U. ReadFile.exe');
  112.    Writeln('Pascal Genorated Typed File Reader Utility by George Slaterpryce');
  113.    writeln('(C) 1996 George Slaterpryce A.K.A. Illogical Error');
  114.    Writeln('This utility is Freeware.');
  115.    Writeln;
  116.    writeln('Usage ReadFile /[S,C,#,T,?] <filename.dat>');
  117.    textcolor(17);write('               option');textcolor(green);write('      file name');
  118.    writeln('');
  119.    textcolor(7);
  120.    writeln;
  121.    writeln('Command line Parameters');
  122.    writeln('/S   Reads file of strings');
  123.    writeln('/C   Reads file of chars');
  124.    writeln('/#   Reads file of Integers');
  125.    writeln('/T   Reads Text Files');
  126.    writeln('/?   This help screen');
  127.    end;
  128.  
  129. (***************************************************************************)
  130.  
  131.  
  132. begin
  133. count := 0; (*initialize all variables*)
  134. clrscr;
  135. didit := false;
  136. clrscr;
  137.  
  138.  
  139. (*Start our Hex viewing or Binary viewing*)
  140.     IF paramstr(1) = '/h' then
  141.         begin
  142.       if paramstr(2) = '' then notice2(didit);   (*See if the user typed*)
  143.       if paramstr(2) <> '' then           (*a file name if and they didnt*)
  144.       begin                               (*tell them*)
  145.       Assign(F2, paramstr(2));            (*if they did go on with the *)
  146.       Reset(F2);                          (*function*)
  147.       writeln;
  148.       writeln;
  149.       while not Eof(F2) do
  150.       begin
  151.       Read(F2, ch);
  152.       if ch > char(31) then          (*throw out all the "trash" chars*)
  153.       begin                          (* (the higher ended ascii codes and*)
  154.       if ch < char(127) then         (* some of the lower ones to make it*)
  155.                                      (*into more readable code*)
  156.       begin
  157.       IF count = 1500 then (*this is how many characters we can show on a *)
  158.       begin;               (*screen at one time well actually you can show*)
  159.       writeln;             (*2000 characters at a time(on a 80x25 standard*)
  160.       writeln;             (*screen but 1500 gives you a little play room *)
  161.       writeln('pause');
  162.       readkey;
  163.       writeln;
  164.       writeln;
  165.       clrscr;
  166.       end;
  167.       count := count + 1;
  168.       Write(Ch);
  169.       end;
  170.       end;
  171.     end;
  172.     close(F2);
  173.     didit := true;
  174.   end;
  175.   end;
  176.  
  177. (*end of hex/binary viewing*)
  178. (***************************************************************************)
  179.  
  180.  
  181. (*From here on down i added on some features that you could use to make*)
  182. (*a more specialized view simple crup really :) but hey what the hell *)
  183.  
  184.  
  185.     (* this little function here is to eleminate a rather stupid bug i had
  186.     when the user typed nothing after fileread *)
  187.     IF paramstr(1) = '' then
  188.     begin
  189.     assign(F, 'Error.txt');
  190.     rewrite(F);
  191.     close(F);
  192.     notice3;
  193.     end;
  194.     (*******************************************)
  195.  
  196.     IF paramstr(1) = '/S' then
  197.     begin
  198.     if paramstr(2) = '' then notice2(didit);
  199.     if paramstr(2) <> '' then
  200.     begin
  201.     Assign(F, paramstr(2));
  202.     Reset(F);
  203.     while not Eof(F) do
  204.     begin
  205.       Read(F, strng);
  206.       Write(strng);
  207.       writeln;
  208.     end;
  209.     close(F);
  210.    end;
  211.    didit := true;
  212.    end;
  213.  
  214.   IF paramstr(1) = '/s' then
  215.   begin
  216.   if paramstr(2) = '' then notice2(didit);
  217.   if paramstr(2) <> '' then
  218.   begin
  219.     Assign(F, paramstr(2));
  220.     Reset(F);
  221.     while not Eof(F) do
  222.     begin
  223.       Read(F, strng);
  224.       Write(strng);
  225.       writeln;
  226.     end;
  227.     close(F);
  228.     didit := true;
  229.   end;
  230.   end;
  231.  
  232.    IF paramstr(1) = '/C' then
  233.     begin
  234.     if paramstr(2) = '' then notice2(didit);
  235.     if paramstr(2) <> '' then
  236.     begin
  237.     Assign(F2, paramstr(2));
  238.     Reset(F2);
  239.     while not Eof(F2) do
  240.     begin
  241.       Read(F2, ch);
  242.        if ch = char(7) then ch := char(255);
  243.       Write(Ch);
  244.       end;
  245.     close(F2);
  246.     didit := true;
  247.    end;
  248.    end;
  249.  
  250.     IF paramstr(1) = '/c' then
  251.      begin
  252.      if paramstr(2) = '' then notice2(didit);
  253.      if paramstr(2) <> '' then
  254.     begin
  255.     Assign(F2, paramstr(2));
  256.     Reset(F2);
  257.     while not Eof(F2) do
  258.     begin
  259.       Read(F2, ch);
  260.       if ch = char(7) then ch := char(255);
  261.       Write(Ch);
  262.     end;
  263.     close(F2);
  264.     didit := true;
  265.   end;
  266.   end;
  267.  
  268. IF paramstr(1) = '/#' then
  269.     begin
  270.     if paramstr(2) = '' then notice2(didit);
  271.     if paramstr(2) <> ''  then
  272.     begin
  273.     Assign(F3, paramstr(2));
  274.     Reset(F3);
  275.     while not Eof(F3) do
  276.     begin
  277.       Read(F3, num);
  278.       Write(num);
  279.       writeln;
  280.       end;
  281.   close(f3);
  282.     didit := true;
  283.   end;
  284.   end;
  285.  
  286. IF paramstr(1) = '/T' then
  287.     begin
  288.     if paramstr(2) = '' then notice2(didit);
  289.     if paramstr(2) <> '' then
  290.     begin
  291.     Assign(F4, paramstr(2));
  292.     Reset(F4);
  293.     while not Eof(F4) do
  294.     begin
  295.       Readln(F4, strng);
  296.       Writeln(strng);
  297.    end;
  298.     close(F4);
  299.   end;
  300.   didit := true;
  301.   end;
  302.  
  303. IF paramstr(1) = '/t' then
  304.     begin
  305.     if paramstr(2) = '' then notice2(didit);
  306.     if paramstr(2) <> '' then
  307.     begin
  308.     Assign(F4, paramstr(2));
  309.     Reset(F4);
  310.     while not Eof(F4) do
  311.     begin
  312.       Readln(F4, strng);
  313.       Writeln(strng);
  314.    end;
  315.     close(F4);
  316.   end;
  317.   didit := true;
  318.   end;
  319.  
  320.  
  321.  
  322.  
  323. IF didit = false then notice3;
  324. IF paramstr(1) = '/?' then notice3;
  325.  
  326.  
  327. Writeln;
  328. textcolor(red);
  329. writeln('operation done');
  330. textcolor(7);
  331. writeln('');
  332.  
  333.  
  334. end.
  335.  
  336.  
  337.  
  338.